package org.lanzier.common.utils;

import java.util.Map;

/**
 * @author lansb
 * Map utils
 */
public class MapUtils { 
	public static String getString(Map map, String key) {
		return getString(map, key, "");
	}
	public static String getString(Map map, String key, String def) {
		return map.get(key) == null ? def : map.get(key).toString();
	}
	public static int getInt(Map map, String key, int def) {
		return map.get(key) == null ? def : Integer.parseInt(map.get(key).toString());
	}
	public static int getInt(Map map, String key) {
		return getInt(map, key, 0);
	}
	public static float getFloat(Map map, String key, int def) {
		return map.get(key) == null ? def : Float.parseFloat(map.get(key).toString());
	}
	public static float getFloat(Map map, String key) {
		return getFloat(map, key, 0);
	}
	public static double getDouble(Map map, String key, int def) {
		return map.get(key) == null ? def : Double.parseDouble(map.get(key).toString());
	}
	public static double getDouble(Map map, String key) {
		return getDouble(map, key, 0);
	}
}
